<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>总进球统计</title>
    <script src="../static/js/jquery-3.7.1.min.js" type="text/javascript"></script>
    <style>
    table {
        border-collapse: collapse; /*合并边框*/
        width: 100%; /*设置表格宽度*/
    }

    th, td {
        border: 1px solid black; /*设置边框线样式、颜色和大小*/
        padding: 8px; /*设置内边距*/
    }
    .zhong{
            background-color: red;
        }
   .peizhong{
            background-color: magenta;
        }
.xiao_info{
				display: flex;
				                flex-direction: row;
				                flex-wrap: nowrap;
				                justify-content: center;
				                align-items: center;
			}
			.xiao_r1{
				font-size: 30px;
				font-weight: 100;
			}
			.xiao_l{
				padding-left: 5px;
			}
			.xiao_l>div{
				border-bottom: 1px solid black;
			}
        .peid{
            background-color: gray;
        }
        .qiu{
            background-color: darkcyan;
        }
        .yuzhong{
            background-color: chartreuse;
        }
        .span1{
            font-size: 30px;
            font-weight: 100;
            color: red;
        }
        #matchinfo>span{
            padding: 10px;
        }
        .yuche{
            background-color: chartreuse;
        }
        .xuanzhong{
            background-color: royalblue;
            color: white;
            border: 2px solid greenyellow;
        }
        #xuanzheqiu>span{
            border: 1px solid black;
            border-radius: 10px;
            padding: 5px;
        }

</style>

</head>
<body>

<div id="matchinfo" style="color: royalblue;font-size: 25px;text-align: center;">

</div>

<div id="xuanzheqiu" style="color: red;font-size: 25px;text-align: center;margin-bottom: 5px;">

</div>
<div style="text-align: center">
    开始：<input type="date" value="2024-01-01" id="start">
    至：<input type="date" value="2025-12-31" id="end">
    <input type="button" onclick="load()" value="查询"/>
</div>

<div id="fenxi" style="color: royalblue;font-size: 25px;text-align: center;border: 1px solid red;">
数据统计：
</div>
<table id="tjds">
        <caption>总进球统计/预测</caption>
        <thead>
            <tr>
                <td>赔数\球数</td>
                <td>0球</td>
                <td>1球</td>
                <td>2球</td>
                <td>3球</td>
                <td>4球</td>
                <td>5球</td>
                <td>6球</td>
                <td>7+球</td>
                <td>赔数统计</td>
            </tr>
        </thead>
        <tbody>
        </tbody>
</table>

</body>

<script type="text/javascript">
    $(function () {
       load();
    });
            // 加载数据
        function load() {
                //加载前清空之前页面的显示
                $("#tjds>tbody").html("");
                $("#matchinfo").html("");
                $("#fenxi").html("");
                // 获取后台数据
                $.get('/ttg_tj_ds', {"start":$('#start').val(),"end":$('#end').val()}, function (r) {

                    var fenxi = r.fenxi;
                    var tj_arr = new Array();
                    tj_arr.push("奖金："+fenxi.jiangji)
                    tj_arr.push("统计场次："+fenxi.totalNum)
                    tj_arr.push("命中场次："+fenxi.zhong)
                    var yu = fenxi.jiangji - fenxi.totalNum;
                    tj_arr.push("差额："+yu.toFixed(2))
                     tj_arr.push("差额率："+(yu/fenxi.totalNum).toFixed(2))
                    if(yu>=0){
                        tj_arr.push("结论：<span style=\"color: red;\">此方案可执行！！！</span>")
                    }else{
                        tj_arr.push("结论：<span style=\"color: black;\">此方案可执行！！！</span>")
                    }
                    $("#fenxi").append(tj_arr.join(" "));
                    var tjds_arr = new Array();
                    var tjds = r.tjds;//统计信息
                    for (var i = 0; i < tjds.length; i++) {
                        tjds_arr.push("<tr>");
                        tjds_arr.push("<td>");
                        if (i < tjds.length - 1) {
                            tjds_arr.push((i + 1) + "赔");
                        } else {
                            tjds_arr.push("球统计");
                        }
                        tjds_arr.push("</td>");
                        var tc = 0;
                        for (var j = 0; j < tjds[i].length; j++) {
                            tjds_arr.push("<td>");
                            if (tjds[i][j][0] > 0) {
                                tjds_arr.push(...showinfo(tjds[i][j], j));
                                tc += tjds[i][j][0];
                            }
                            if (j == 8 & i == 8) {
                                tjds_arr.push("共<span class='span1'>" + tc + "</span>条数据");
                            }
                            tjds_arr.push("</td>");
                        }
                        tjds_arr.push("</tr>");
                    }
                    $("#tjds").append(tjds_arr.join(" "));
                });
        }
    function selectA(e) {
        var id = $(e).attr("id");
        var d = $(e).attr("d");

        if(d == 0){
            $("#"+id).attr("d",1);
            $("#"+id).addClass("xuanzhong");

        }else {
             $("#"+id).attr("d",0);
             $("#"+id).removeClass("xuanzhong");
        }
         $("#xuanzheqiu").html("");
        //获取所有选择的
            var qius = $('.xuanzhong');
            var arr = [];
            arr.push("预测：");
            for(var i=0;i<qius.length;i++){
                var q ="<span class=''>"+$(qius[i]).attr("id")+"球</span>";
                arr.push(q);
            }
            $("#xuanzheqiu").append(arr.join(" "));

    }

    // 显示统计信息里面的表格信息
    function showinfo(d,j) {
           var arr = new Array();
           if(d[d.length-1]==1){
               arr.push("<div class=\"xiao_info yuche\" id="+j+" d='0' onclick=\"selectA(this)\">");
               arr.push("<input type=\"hidden\" value="+j+"/>");
           }else{
              arr.push("<div class=\"xiao_info\">");
           }

           arr.push("<div>");
           var s1 = "<div class=\"xiao_r1\" title=\"命中数量\">"+d[0]+"</div>";
           arr.push(s1);
           var s2 = "<div class=\"xiao_r2\" title=\"命中率\">"+d[1]+"</div>";
           arr.push(s2);
           arr.push("</div>");
           arr.push("<div class=\"xiao_l\">");
           var s3 = "<div title=\"当前遗漏\">"+d[5]+"</div>";
           arr.push(s3);
           var s4 = "<div title=\"平均遗漏\">"+d[3]+"</div>";
           arr.push(s4);
           arr.push("</div>");
           arr.push("<div class=\"xiao_l\">");
           var s5 = "<div title=\"最大间隔\">"+d[2]+"</div>";
           arr.push(s5);
           var s6 = "<div title=\"方差\">"+d[4]+"</div>";
           arr.push(s6);
           arr.push("</div>");
           arr.push("<div class=\"xiao_l\">");
           var s5 = "<div title=\"出现可能性\">"+d[7]+"</div>";
           arr.push(s5);
           var s6 = "<div title=\总奖金\">"+d[6]+"</div>";
           arr.push(s6);
           arr.push("</div>");
           arr.push("</div>");
           return arr;

       }

       // 显示将要预测的比赛信息
       function shouyuinfo(d) {
           var arr = new Array();
           arr.push("<span>"+d.info.matchDate+"</span><span>"+d.info.matchTime+"</span><span>"+d.info.matchNumStr+"</span><span>"+d.info.homeTeamAbbName+"vs"+d.info.awayTeamAbbName +"</span>");
           $("#matchinfo").append(arr.join(" "));
       }

</script>
</html>